from selenium.webdriver.common.by import By
from pages.base_page import Page

class LoginPage(Page):

    ele_email = (By.NAME,u'email')
    ele_password = (By.NAME,u'password')
    ele_sign_in = (By.XPATH,u'//button[@data-tag="formButton"]')

    def __init__(self,driver,url,email_name,passwd, site_id):
        Page.__init__(self,driver,url)
        self.email_name = email_name
        self.passwd = passwd
        # self.url = url

    # move the method to base classes
    # def goto_page(self):
    #     self.driver.get(self.base_url)

    def login(self):
        self.input_text(self.ele_email,self.email_name)
        self.input_text(self.ele_password,self.passwd)
        self.click(self.ele_sign_in)


    def clear_input(self):
        self.find_element(*self.ele_email).clear()
        self.find_element(*self.ele_password).clear()